var utilMd5 = require('md5.js');
module.exports = {
  host: 'https://a.onepartygo.com/router',
  getSign: function () {
    let key = 'app_key0617CA8376F9901F28FF46B69BF9CF55formatjsonlocalezh_CNmethodopg.eventPromote.findopgAppVersion1.4.9pageNumber1pageSize10session' + session +' sign_methodmd5timestamp1499936931714v1.0'
    return utilMd5.hexMD5(key)
  },
  request: function (url, method, data, success, fail) {
    wx.request({
      url: this.host + url,
      method: method,
      data: data,
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'X-Requested-Page': 'json'
      },
      success: success,
      fail: fail
    })
  },
  getProducts: function (success, fail, data = {}) {
    var md = this.getSign()
    data.pid = '303084713666505'
    data.sign = md
    data.action = 'list_product'
    this.request('/Pt/index', 'POST', data, success, fail)
  },
}